package controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import po.Product;
import service.ProductService;
import utils.ResUtils;

import java.util.List;
@Controller
public class ProductController {
    @Autowired
    private ProductService productService;

    // 获取类型列表数据
    @GetMapping("/products")
    @ResponseBody
    public Object AllProducts() {

        List<Product> res = this.productService.allProduct();

        if ( res != null) {
            return ResUtils.Success(1,"查询成功",res);
        } else {
            return ResUtils.Fail(0,"没有数据");
        }
    }
}
